<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>考勤录入</title>
<jsp:include page="${home}/assets/common_inc_new.jsp"  flush="true"></jsp:include>
<script type="text/javascript" src="/xyzg/system/common/scripts/zDialog.js"></script>
<script type="text/javascript" src="/xyzg/scripts/zTree/js/jquery.ztree.all-3.5.min.js"></script>
<script src="/xyzg/workatten/attendance/deptTreeJs.js"></script>
<link rel="stylesheet" href="/xyzg/scripts/zTree/css/zTreeStyle/zTreeStyle.css" type="text/css">
<script type="text/javascript" src="${home}/system/common/scripts/utils.js"></script>
<link rel="stylesheet" type="text/css" href="../css/index.css">
<script type="text/javascript">
var result;
var page_current=1;
var page_size=0;
var page_interval=10;

function ui_listReqInfos() {
    page_size=$("#txtPageNum").val();
    var queryCallBack=function(reqInfos,callResult){
        if(reqInfos!=null){
            $.dialog.tips("查询成功...");
            ui_addReqInfo(reqInfos.content.result.records);
            var htmlMsg2="";
            //var htmlMsg2=OutPageListAjax(10,  1,  25,  pageChangeCallback,  10);
            htmlMsg2=OutPageListAjax(page_size, page_current, reqInfos.content.result.total_count, pageChangeCallback, page_interval);
            $("#PageContent").html(htmlMsg2);
            page_current=1;
        }
    }
    listReqInfos(queryCallBack);
}
function pageChangeCallback (pageid){
    page_current=pageid;
    ui_listReqInfos();
}
function listReqInfos(callBackList){
    var head = {
        "service_name":"MemberService",
        "operation_name":"queryMemberList"
    }

    var param = {
        "deptId": $("#dept_id").val(),
        "query": $("#approval_query").val(),
        "pageNum":page_current,
        "pageSize":page_size
    }

    var myCallBack=function(data,callResult){
        //ui_enableServiceMask(false);
        if(callBackList){
            callBackList(data,callResult);
        }
    }
    var options = {
        "handleError": false,
        "showProgressBar":false,
        "timeout":60000*10
    }
    //ui_enableServiceMask(true);
    $.ServiceAgent.JSONInvoke(head, param, myCallBack, options);
}

function obj2Str(obj) {
  return JSON.stringify(obj).replace(/"/g, "'");
}

function chooseApproval(approval) {
  parent.addApproval(approval);
  window.location.href = "add.jsp";
  parent.diag.close();
}

function ui_addReqInfo(data){
	var tableTh = "<tr>"
		+ "<th width=\"10%\">序号</th>"
		+ "<th width=\"10%\">姓名</th>"
		+ "<th width=\"10%\">性别</th>"
		+ "<th width=\"10%\">身份证号</th>"
		+ "<th width=\"10%\">警号</th>"
		+ "<th width=\"10%\">手机号</th>"
		+ "<th width=\"10%\">所属部门</th>"
		+ "<th width=\"10%\">操作</th>"
	+ "</tr>";
	$("#resultgrid").html(tableTh);
		for(var i=0;i<data.length;i++){
				var reqInfo=data[i];
        var itemStr = obj2Str(reqInfo);
				var htmlMsg="<tr>"
				+"<td align=\"center\">"+(i + 1)+"</td>"
				+"<td align=\"center\">"+reqInfo.name+"</td>"
				+"<td align=\"center\">"+reqInfo.gender+"</td>"
				+"<td align=\"center\">"+(reqInfo.idcard || '无')+"</td>"
				+"<td align=\"center\">"+(reqInfo.policecode || '无')+"</td>"
				+"<td align=\"center\">"+(reqInfo.mobile || '无')+"</td>"
				+"<td align=\"center\">"+reqInfo.dept+"</td>"
				+"<td align=\"center\" class=\"choose\" onclick=\"chooseApproval(" + itemStr + ")\">选择</td>"
				+"</tr>";
				$("#resultgrid").append(htmlMsg);

			}
	}

  function ShowAction() {
    var param = {'0':'模版描述'};
    var tit = "部门选择";
    jsdialog(tit, RpTpl($("#recharge-tpl").html(), param), "", "None", function (data) {  alert(data);},
      function (data) {
        //alert('ok---'+right_click_node.id);
        //alert(data);
        $("#txtdept").val(right_click_node.name);
        $("#dept_id").val(right_click_node.id);
      },
      function () {
        createTree();
      });
  }
  function RpTpl(tpl, obj) {
    var re = tpl;
    if (!tpl || tpl.length <= 0) return re;
    if (!obj || typeof obj != "object") return re;
    for (k in obj) {
      re = re.replace("{#" + k + "#}", obj[k]);
    }
    return re;
  }

	function add() {
		window.location.href="add.jsp";
	}

	$(document).ready(function(){
    ui_listReqInfos();
	});
</script>

<!-- 部门选择弹出框 -->
<script id="recharge-tpl" type="text/template">
  <div id="role" style="width: 250px; float: left; ; height: 300px;background: #eeeeee">
    <div class="title">部门列表</div>
    <div id="treeParentArea" valign=top style="width: 100%;height: 500px;">
      <ul id="tree" class="ztree" style="overflow:auto;margin:0px;height:698px"></ul>
    </div>
  </div>
</script>

</head>
<body class="mainbody">
			<!-- 导航栏 -->
			<div class="location">
				<a onclick="javascript:if(window.parent != window){parent.diag.close();};" class="back"><i></i><span>返回</span></a>
				<i class="arrow"></i>
				<span>添加审批人</span>
				</a>
			</div>

			<!-- 操作栏 -->
			<div class="toolbar-wrap">
				<div id="floatHead" class="toolbar">
					<div class="r-list" style="float: none">
						<input type="hidden" id="dept_id" class="operation_date" placeholder="部门" />
						<input type="text" id="txtdept" placeholder="部门" style="float: left" style="width: 150px;" class="keyword date" onclick="ShowAction()" />
						<input type="text" id="approval_query" class="keyword date" placeholder="姓名、身份证号、警号"  />
						<!-- <a id="lbtnSearch" class="reset" onclick="ui_listReqInfos();"><span>查询</span></a> -->
						<a id="lbtnSearch" class="btn-search" onclick="ui_listReqInfos();"><i></i><span>查询</span></a>
					</div>
				</div>
			</div>

		<!--查询结果列表-->
		<table width="100%" border="0" cellpadding="0" cellpadding="0" class="ltable" id="resultgrid">
			<tr>
				<th width="10%">序号</th>
				<th width="10%">姓名</th>
				<th width="10%">性别</th>
				<th width="10%">身份证号</th>
				<th width="10%">警号</th>
				<th width="10%">手机号</th>
				<th width="10%">部门</th>
				<th width="10%">操作</th>
			</tr>
		</table>

		<!--内容底部-->
		<div class="line30"></div>
		<div class="pagelist">
			<div class="l-btns">
				<span>显示</span>
				<input type="text" name="txtPageNum" value="10"
				onchange="javascript:setTimeout(&#39;__doPostBack(\&#39;txtPageNum\&#39;,\&#39;\&#39;)&#39;, 0)"
				onkeypress="if (WebForm_TextBoxKeyHandler(event) == false) return false;"
						id="txtPageNum" class="pagenum"
						onkeydown="return checkNumber(event);"/>
				<span>条/页</span>
			</div>
			<div id="PageContent" class="default">
			</div>
		</div>

</body>
</html>
